package com.ruoyi.web.controller.officalWebsite;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.kiku.domain.OfficialWebsiteBannerInfo;
import com.ruoyi.kiku.service.IOfficialWebsiteBannerInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 轮播信息Controller
 *
 * @author TT
 * @date 2025-08-25
 */
@RestController
@RequestMapping("/kiku/websiteBanner")
public class OfficialWebsiteBannerInfoController extends BaseController
{
    @Autowired
    private IOfficialWebsiteBannerInfoService officialWebsiteBannerInfoService;

    /**
     * 查询轮播信息列表
     */
    @PreAuthorize("@ss.hasPermi('kiku:websiteBanner:list')")
    @GetMapping("/list")
    public TableDataInfo list(OfficialWebsiteBannerInfo officialWebsiteBannerInfo)
    {
        startPage();
        List<OfficialWebsiteBannerInfo> list = officialWebsiteBannerInfoService.selectOfficialWebsiteBannerInfoList(officialWebsiteBannerInfo);
        return getDataTable(list);
    }

    /**
     * 导出轮播信息列表
     */
    @PreAuthorize("@ss.hasPermi('kiku:websiteBanner:export')")
    @Log(title = "轮播信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OfficialWebsiteBannerInfo officialWebsiteBannerInfo)
    {
        List<OfficialWebsiteBannerInfo> list = officialWebsiteBannerInfoService.selectOfficialWebsiteBannerInfoList(officialWebsiteBannerInfo);
        ExcelUtil<OfficialWebsiteBannerInfo> util = new ExcelUtil<OfficialWebsiteBannerInfo>(OfficialWebsiteBannerInfo.class);
        util.exportExcel(response, list, "轮播信息数据");
    }

    /**
     * 获取轮播信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('kiku:websiteBanner:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(officialWebsiteBannerInfoService.selectOfficialWebsiteBannerInfoById(id));
    }

    /**
     * 新增轮播信息
     */
    @PreAuthorize("@ss.hasPermi('kiku:websiteBanner:add')")
    @Log(title = "轮播信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OfficialWebsiteBannerInfo officialWebsiteBannerInfo)
    {
        return toAjax(officialWebsiteBannerInfoService.insertOfficialWebsiteBannerInfo(officialWebsiteBannerInfo));
    }

    /**
     * 修改轮播信息
     */
    @PreAuthorize("@ss.hasPermi('kiku:websiteBanner:edit')")
    @Log(title = "轮播信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OfficialWebsiteBannerInfo officialWebsiteBannerInfo)
    {
        return toAjax(officialWebsiteBannerInfoService.updateOfficialWebsiteBannerInfo(officialWebsiteBannerInfo));
    }

    /**
     * 删除轮播信息
     */
    @PreAuthorize("@ss.hasPermi('kiku:websiteBanner:remove')")
    @Log(title = "轮播信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(officialWebsiteBannerInfoService.deleteOfficialWebsiteBannerInfoByIds(ids));
    }
}
